package regex;

public class RegexDemo06 {
    public static void main(String[] args) {
        //method();
        /**
         * 邮箱的模糊匹配
         * zhangsan@126.com
         * 23232323@qq.com
         */
        String regexStr = "\\w+@\\w+\\.\\w+";
        System.out.println("zhangsan@126.com".matches(regexStr));//true
        System.out.println("zhangsan126.com".matches(regexStr));//false
    }

    private static void method() {
        /*  手机号的规则:
         *   1.手机号的长度必须是11位
         *   2.手机号的第一位必须是1
         *   3.手机号的第二位:3或4或5或7或8
         *   4.手机号的后9位位数都必须是数字
         * */
        String regexStr = "1[34578]\\d{9}";
        System.out.println("13534931778".matches(regexStr));//true
        System.out.println("23534931778".matches(regexStr));//false
        System.out.println("2353493a778".matches(regexStr));//false
    }
}
